#pragma once

#include "OtpSession.h"

#include "OtpEnvironment.h"

namespace otp
{
  namespace impl
  {
    class COtpSessionImpl : public otp::IOtpSession
    {
    private:
      otp::COtpEnvironment& m_env;
      OASESS_HANDLE m_handle;
    public:
      COtpSessionImpl(otp::COtpEnvironment& env) : m_env(env), m_handle(NULL)
      {

      }
      ~COtpSessionImpl(void)
      {
        if(isOpen()) close();
      }

      virtual OASESS_HANDLE getHandle(void) const
      {
        return m_handle;
      }

      virtual bool isOpen() const
      {
        return m_handle != NULL;
      }

      virtual void open();
      virtual void close();

      virtual bool lock(const std::string& username, int *ret = NULL);
      virtual bool check(const std::string& username, const std::string& passcode, int *ret = NULL);
      virtual bool next(const std::string& passcode, int *ret = NULL);      

      virtual bool setPIN(const std::string& pin, int *ret = NULL);
    };
  } // namespace impl
} // namespace otp

